<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>
        添加楼栋
    </title>
    <meta content="webkit" name="renderer">
    <meta content="IE=edge,chrome=1" http-equiv="X-UA-Compatible">
    <meta content="width=device-width, initial-scale=1, maximum-scale=1" name="viewport">
    <meta content="black" name="apple-mobile-web-app-status-bar-style">
    <meta content="yes" name="apple-mobile-web-app-capable">
    <meta content="telephone=no" name="format-detection">
    <link href="css/main.css" media="all" rel="stylesheet">
    <script src="lib/loading/okLoading.js" type="text/javascript"></script>
    <style>
        .imgs {
            display: none;
        }
    </style>

</head>
<body>
<div class="x-body">
    <form action="" class="layui-form layui-form-pane" id="add">
        <div class="layui-tab layui-tab-brief" lay-filter="docDemoTabBrief">
            <div class="layui-tab-content">
                <div class="layui-tab-item layui-show">
                    <input name="id" type="hidden" value="">
                    <!--                    <div class="layui-form-item">-->
                    <!--                        <label class="layui-form-label">-->
                    <!--                            <span class='x-red'>*</span>所属小区-->
                    <!--                        </label>-->
                    <!--                        <div class="layui-input-block">-->
                    <!--                            <select id="community_id" name="community_id">-->
                    <!--                                <option value="1">东湖小区</option>-->
                    <!--                                <option value="2">金华万府</option>-->
                    <!--                            </select>-->
                    <!--                        </div>-->
                    <!--                    </div>-->
                    <div class="layui-form-item">
                        <label class="layui-form-label">
                            <span class='x-red'>*</span>楼栋号
                        </label>
                        <div class="layui-input-block">
                            <input autocomplete="off" class="layui-input" lay-verify="required"
                                   name="buildings_number"
                                   placeholder="请输入楼栋号" required="" type="text" value="">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">
                            <span class='x-red'>*</span>整栋层数
                        </label>
                        <div class="layui-input-block">
                            <input autocomplete="off" class="layui-input" lay-verify="number" name="numberOfLayers"
                                   placeholder="请输入数字" required="" type="text" value="">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">
                            <span class='x-red'>*</span>整栋面积
                        </label>
                        <div class="layui-input-block">
                            <input autocomplete="off" class="layui-input" lay-verify="number" name="area"
                                   placeholder="请输入数字" required="" type="text" value="">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">
                            <span class='x-red'>*</span>地理位置
                        </label>
                        <div class="layui-input-block">
                            <input autocomplete="off" class="layui-input" lay-verify="number" name="location"
                                   placeholder="请输入数字" required="" type="text" value="">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <button class="layui-btn" lay-filter="add" lay-submit="" type="button">
                            保存
                        </button>
                    </div>
                    <div style="height:100px;"></div>
                </div>

            </div>

        </div>
    </form>
</div>
<script charset="utf-8" src="lib/layui/layui.js"></script>
<script charset="utf-8" src="js/x-layui.js"></script>
<script>
    layui.use(['element', 'layer', 'form'], function () {
        $ = layui.jquery;//jquery
        lement = layui.element();//面包导航
        layer = layui.layer;//弹出层
        form = layui.form();
        okLoading.close($);

        //监听提交
        form.on('submit(add)', function (data) {
            var buildings_number = $("input[name='buildings_number']").val();
            var numberOfLayers = $("input[name='numberOfLayers']").val();
            var area = $("input[name='area']").val();
            var location = $("input[name='location']").val();
            if (buildings_number == "") {
                layer.msg('栋数名称不能为空！', {icon: 5, time: 2000});
                return false;
            }
            if (numberOfLayers == "") {
                layer.msg('总层数不能为空！', {icon: 5, time: 2000});
                return false;
            }
            if (area == "") {
                layer.msg('总面积不能为空！', {icon: 5, time: 2000});
                return false;
            }
            if (location == "") {
                layer.msg('地理位置不能为空！', {icon: 5, time: 2000});
                return false;
            }
            var data = data.field;
            console.log(data);
            $.ajax({
                type: "post",
                url: "admin/property/addBuilding",
                // String buildingNumber, String totalFloors, String totalAreas,String location
                data: {
                    buildingNumber: buildings_number,
                    totalFloors: numberOfLayers,
                    totalAreas: area,
                    location: location
                },
                dataType: "json",
                success: function (data) {
                    if (data.code == 200) {
                        layer.msg(data.msg, {icon: 6, time: 2000}, function () {
                            window.parent.location.reload();
                            var index = parent.layer.getFrameIndex(window.name);
                            parent.layer.close(index);
                        });
                        return false;
                    } else {
                        layer.msg(data.msg, {icon: 5, time: 2000});
                        return false;
                    }
                }

            });

        });

    })
</script>

</body>
</html>